package com.jss.lanouhn.fristapp.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.jss.lanouhn.fristapp.R;
import com.jss.lanouhn.fristapp.activity.SelecterDetails;

/**
 * Created by lanouhn on 16/9/5.
 */
public class Fragment_Selecter_Details extends Fragment{
    private WebView wv;
    private String urlTop="http://www.liwushuo.com/items/";
    private String url;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=LayoutInflater.from(getContext()).inflate(R.layout.fragment_selecter_details,null);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        wv= (WebView) getView().findViewById(R.id.wv_selecter_details);
        String id=((SelecterDetails)getActivity()).getId();
        url=urlTop+id;
        initData();

    }

    private void initData() {
        WebSettings webSettings = wv.getSettings();
        wv.loadUrl(url);
        webSettings.setJavaScriptEnabled(false);


        wv.reload();
        wv.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);

            }
        });


    }
}
